package org.supda.system.task;

import java.lang.Thread.UncaughtExceptionHandler;

/**
 * 
 * @author SEELE
 * 线程异常处理类
 * 设置该线程由于未捕获到异常而突然终止时调用的处理程序。
 */
public class TaskExceptionHandler implements UncaughtExceptionHandler{

	@Override
	public void uncaughtException(Thread t, Throwable e) {
		String name = t.getClass().getName();
		
		try {
			Thread thread = (Thread) Class.forName(name).newInstance();
			thread.setUncaughtExceptionHandler(new TaskExceptionHandler());
			thread.start();
		} catch (InstantiationException e1) {
			e1.printStackTrace();
		} catch (IllegalAccessException e1) {
			e1.printStackTrace();
		} catch (ClassNotFoundException e1) {
			e1.printStackTrace();
		}

	}

}
